﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace aichat.Entities
{
    [Table("hc_users")]
    public class UserModel
    {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [Column(name: "user_id")]
        public int UserId { get; set; }

        [Column(name: "role_id")]
        public int RoleId { get; set; }

        [Column(name: "user_name")]
        public string? UserName { get; set; }
        [Column(name: "password")]
        public string? Password { get; set; }
        [Column(name: "user_icon")]
        public string? UserIcon { get; set; }
        [Column("real_name")]
        public string? RealName { get; set; }
        [Column("email")]
        public string? Email { get; set; }
        [Column(name: "state")]
        public int State { get; set; }
        [Column("card_id")]
        public string? CardId { get; set; }
        [Column("fingerprint_id")]
        public string? FingerprintId { get; set; }

        // 时间戳
        [Column("created_at")]
        public DateTime CreatedAt { get; set; } = DateTime.Now;
        [Column("updated_at")]
        public DateTime? UpdatedAt { get; set; }
        [Column("last_login_at")]
        public DateTime? LastLoginAt { get; set; }

        // 会员相关
        [Column("is_vip")]
        public bool IsVip { get; set; } = false;
        [Column("vip_expire_date")]
        public DateTime? VipExpireDate { get; set; }
        [Column("vip_type")]
        public VipType VipType { get; set; } = VipType.None;
        
        // 对话次数限制
        [Column("daily_chat_count")]
        public int DailyChatCount { get; set; } = 0;
        [Column("last_chat_date")]
        public DateTime LastChatDate { get; set; } = DateTime.Today;
        
        // 用户状态
        [Column("is_active")]
        public bool IsActive { get; set; } = true;
    }

    public enum VipType
    {
        None = 0,
        Monthly = 1,
        Yearly = 2,
        Permanent = 3
    }
}
